package com.hanthink.web.controller.pc;

import com.hanthink.common.annotation.Log;
import com.hanthink.common.core.controller.BaseController;
import com.hanthink.common.core.domain.AjaxResult;
import com.hanthink.common.core.domain.model.LoginUser;
import com.hanthink.common.core.page.TableDataInfo;
import com.hanthink.common.enums.BusinessType;
import com.hanthink.common.utils.DateUtils;
import com.hanthink.common.utils.ServletUtils;
import com.hanthink.common.utils.poi.ExcelUtil;
import com.hanthink.framework.web.service.TokenService;
import com.hanthink.system.domain.EmXflh;
import com.hanthink.system.domain.repair.RepairPlan;
import com.hanthink.system.service.IEmXflhService;
import com.hanthink.system.service.repair.IRepairPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;


@RestController
@RequestMapping("/system/repairplan")
public class RepairPlanController extends BaseController
{
    @Autowired
    private IRepairPlanService emXflhService;

    @Autowired
    private TokenService tokenService;

    @PreAuthorize("@ss.hasPermi('system:repairplan:list')")
    @GetMapping("/list")
    public TableDataInfo list(RepairPlan repairPlan)
    {
        startPage();
        List<RepairPlan> list = emXflhService.selectRepairPlanList(repairPlan);
        return getDataTable(list);
    }




    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(emXflhService.selectRepairPlanById(id));
    }


    @Log(title = "维修计划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RepairPlan repairPlan)
    {
        repairPlan.setCreatetime(DateUtils.getNowDate());
        repairPlan.setResourcefrom("WEB端");
        return toAjax(emXflhService.insertRepairPlan(repairPlan));
    }


    @Log(title = "维修计划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RepairPlan repairPlan)
    {
        return toAjax(emXflhService.updateRepairPlan(repairPlan));
    }


    @Log(title = "维修计划", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(emXflhService.deleteRepairPlanByIds(ids));
    }


}
